<script setup>
import HeaderNavTabarVue from '@/components/HeaderNavTabar/HeaderNavTabar.vue'
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import {
  administrativeApplyApiInfo,
  attendanceApplyInfoApi,
  financialApplyApiInfo,
  personnelApplyApiInfo,
} from '@/api/attendance'

const title = ref('')
const userName = ref('')

const defineDataList = ref(null)
onLoad(async (v) => {
  let { item } = v
  let { appType, applyId, type, nickName } = JSON.parse(decodeURIComponent(item))
  title.value = type
  userName.value = nickName
  let params = {
    applyId
  }
  switch (appType) {
    case '考勤':
      defineDataList.value = await attendanceApplyInfoApi(params)
      break
    case '财务':
      defineDataList.value = await financialApplyApiInfo(params)
      break
    case '人事':
      defineDataList.value = await administrativeApplyApiInfo(params)
      break
    case '行政':
      defineDataList.value = await personnelApplyApiInfo(params)
      break
    case '其他':
      break
  }
})
</script>

<template>
  <view>
    <HeaderNavTabarVue :title="title" />
    <view class="defineView-box">
      <view class="box-deader">
        <image src="/static/images/profile.jpg" />
        <h3>{{ userName }}的经营性付款申请</h3>
        <text class="审批中">审批中</text>
      </view>
    </view>
  </view>
</template>

<style scoped lang="scss">
@import '@/static/style/index.scss';

.defineView-box {
  .box-deader {
    width: 100%;
    display: flex;
    align-items: center;
    background: #fff;
    padding: 20rpx;

    image {
      width: 80rpx;
      height: 80rpx;
      margin-right: 20rpx;
    }

    h3 {
      margin-right: 10rpx;
    }

    text {
      @include flex($justify: center, $align: center);
      padding: 0 8rpx;
      border-radius: 5rpx;
      font-size: 24rpx;
    }

    .审核通过,
    .已通过 {
      color: #00b42a;
      background-color: #e8ffea;
    }

    .待审核,
    .审批中 {
      color: #ff7d00;
      background-color: #fff7e8;
    }

    .驳回 {
      color: $btn-error-color;
      background-color: $btn-error-bg;
    }

    .已撤销 {
      color: #86909c;
      background-color: #f2f3f5;
    }
  }
}
</style>
